#include "server_socket.h"
#include "http_client.h"
#include "socket_exception.h"
#include <string>
#include <iostream>

using namespace std;

int main ( void )
{
  cout << "running....\n";

  try
    {
      // Create the socket
      ServerSocket server ( 30000 );
      //HttpClient vote (50000);

      while ( true )
	{

	  ServerSocket new_sock;
	  //HttpClient new_client;
	  server.accept ( new_sock );
	  //vote.accept (new_client);

	  try
	    {
	      while ( true )
		{
		  std::string data;
		  new_sock >> data;
		  //new_client >> data;
		  new_sock << data;
		  //new_client << data;
		}
	    }
	  catch ( SocketException& ) {}

	}
    }
  catch ( SocketException& e )
    {
      cout << "Exception was caught:" << e.description() << "\nExiting.\n";
    }

  return 0;
}

